<template>
	<view>
		<qf-image-cropper v-if="type==1" :width="300" :height="200" @crop="handleCrop"></qf-image-cropper>
		<qf-image-cropper v-else-if="type==4" :width="200" :height="200" :radius="200" @crop="handleCrop"></qf-image-cropper>
		<qf-image-cropper v-else :width="400" :height="300" @crop="handleCrop"></qf-image-cropper>
	</view>
</template>

<script>
	import QfImageCropper from '@/uni_modules/qf-image-cropper/components/qf-image-cropper/qf-image-cropper.vue';
	import {
		uploadXpPath
	} from "@/api/merchants/merchants.js"
	export default {
		components: {
			QfImageCropper
		},
		data() {
			return {
				type: '',
			}
		},
		onLoad(e) {
			this.type = e.type
		},
		methods: {
			handleCrop(e) {
				let that = this
				let pages = getCurrentPages()
				let prevPage = pages[pages.length - 2]; // 上级页面实例
				let data = {
					filePath: e.tempFilePath
				}
				console.log('参数',data)
				uni.showLoading({
					title:'加载中',
					mask:true
				})
				uploadXpPath(data).then(response => {
					if (that.type == 1) {
						prevPage.$vm.model1.info.businessLicenseUrl = response.data;
					} else if (that.type == 2) {
						prevPage.$vm.model1.info.facadeUrl = response.data;
					} else if (that.type==3) {
						prevPage.$vm.model1.info.internalUrls = response.data;
					}else if(that.type==4){
						prevPage.$vm.model1.info.head = response.data;
					}
					uni.hideLoading()
					that.$tab.navigateBack(1)
				})
				// uni.previewImage({
				//     urls: [e.tempFilePath],
				//     current: 0
				// });

			}
		}
	}
</script>